package com.hyt.it.ogt.ks.login.endpoint;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.oauth2.provider.endpoint.FrameworkEndpoint;
import org.springframework.security.oauth2.provider.token.ConsumerTokenServices;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author liuq
 * @ClassName: RevokeTokenEndpoint
 * @Description: 注销token的端点
 * @date 2018年6月4日
 */
@FrameworkEndpoint
public class RevokeTokenEndpoint {

    @Autowired
    private ConsumerTokenServices consumerTokenServices;

    @RequestMapping(value = "/oauth/token", method = RequestMethod.DELETE)
    @ResponseBody
    public Boolean revokeToken(String access_token) {
        if (this.consumerTokenServices.revokeToken(access_token)) {
            return true;
        }
        return false;
    }
}
